#include "stringlist.h"


bool StringList::Add(QString entry)
{
    try
    {
        entry[0] = entry[0].toUpper();
        list.push_back(entry);
        return true;
    }
    catch(...)
    {
        return false;
    }
}
bool StringList::HasEntry(QString entry)
{
    bool has = false;
    for (int i = 0; i < list.size(); i++)
        if (list[i].toLower() == entry.toLower())
            has = true;
    return has;
}

bool StringList::Remove(QString entry)
{
    bool removed = false;
    for (int i = 0; i < list.size(); i++)
        if (list[i] == entry)
        {
            list.erase(list.begin()+i);
            removed = true;
        }
    return removed;
}

int StringList::Size()
{
    return list.size();
}

bool StringList::RemoveAll()
{
    list.clear();
    if (list.size() == 0)
        return true;
    else
        return false;
}

bool StringList::Remove(vector<QString>::iterator f, vector<QString>::iterator t)
{
    list.erase(f, t);
}

QString StringList::Get(int i)
{
    if (i >= list.size())
        return "";
    else
        return list[i];
}

vector<QString>::iterator StringList::Begin()
{
    return list.begin();
}

vector<QString>::iterator StringList::End()
{
    return list.end();
}
